<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        body,
        html {
            width: 100%;
            height: 100%;
        }

        #box {
            width: 100%;
            height: 100%;
        }

        #box ul {
            width: 100%;
            height: 100%;
            list-style: none;
            position: relative;
        }

        #box ul li {
            width: 250px;
            height: 360px;
            /*border: 1px solid #000;*/
            position: absolute;
            /*left: 0;*/
            /*top: 0;*/
            background-color: #fff;
            transition: all 1s;
            box-shadow: 0 0 3px #000;
        }

        #box li img {
            width: 450px;
            height: 360px;
        }

        #box ul li.curr {
            transform: rotate(0deg) translate(-50%, -50%) scale(1.5) !important;
            /*transform: rotate(90deg) !important;*/

            left: 50% !important;
            top: 50% !important;
            z-index: 998;
        }
    </style>
</head>

<body>
    <div id="box">
        <ul>
            <li><img src="./images/1.jpg" alt=""></li>
            <li><img src="./images/2.jpg" alt=""></li>
            <li><img src="./images/3.jpeg" alt=""></li>
            <li><img src="./images/4.jpeg" alt=""></li>
            <li><img src="./images/5.jpeg" alt=""></li>
            <li><img src="./images/6.jpg" alt=""></li>
            <li><img src="./images/7.jfif" alt=""></li>
            <li><img src="./images/8.jpeg" alt=""></li>
            <li><img src="./images/9.jfif" alt=""></li>
            <li><img src="./images/10.jfif" alt=""></li>
        </ul>
    </div>
</body>
<script>

    // 获取元素对象
    var box = document.getElementById('box');
    var oul = document.querySelector('ul')
    var list = document.querySelectorAll('li')

    // 2.获取屏幕的宽度/高度
    var screenW = document.documentElement.clientWidth - 250;
    var screenH = document.documentElement.clientHeight - 360;


    // 2.遍历
    for (var index = 0; index < list.length; index++) {
        var ele = list[index];
        // 1.位置随机
        var x = getRandom(0, screenW);
        var y = getRandom(0, screenH);

        ele.style.left = x + 'px';
        ele.style.top = y + 'px';

        // 2.旋转角度随机
        var angle = getRandom(0, 360);
        ele.style.transform = 'rotate(' + angle + 'deg)';

        // 3.添加点击事件
        ele.onclick = function () {
            // 1.清空所有
            for (var i = 0; i < list.length; i++) {
                list[i].className = '';
            }
            // 2.设置当前
            this.className = 'curr';
        }
    }

    function getRandom(min, max) {
        // 0.9999999 * (100 - 50 + 1) + 50 = 95.9 约等于 95
        return Math.floor(Math.random() * (max - min + 1) + min);
    }

 




</script>

</html>